﻿@using System.Collections.Generic
@using MrCMS.Entities.Widget
@using MrCMS.Helpers
@model Widget
@{
    ViewBag.Title = "Edit | " + Model.WidgetType.BreakUpString();
    Layout = "~/Areas/Admin/Views/Shared/_LayoutPopup.cshtml";
    var cacheExpiryOptions = ViewData["cache-expiry-options"] as List<SelectListItem> ?? new List<SelectListItem>();
}
@using (Html.BeginForm("Edit", "Widget", new { }, FormMethod.Post, new { id = "edit-widget" }))
{
    <fieldset>
        <legend>
            @(!string.IsNullOrWhiteSpace(Model.Name) ? Model.Name : Model.WidgetType.BreakUpString())

            <span class="btn-group  display-inline  pull-right">
                <input type="submit" class="btn-success btn" value="@Resource("Save")" />
            </span>
        </legend>
        @Html.HiddenFor(widget => widget.Id)
        @Html.Hidden("ReturnUrl", ViewData["return-url"])
        <div class="form-group">
            @Html.LabelFor(widget => widget.Name)
            @Html.TextBoxFor(widget => widget.Name, new { @class = "form-control" })
        </div>
        @if (Model.Webpage != null)
        {
            <div class="form-group">
                @Html.InlineCheckboxFor(widget => widget.IsRecursive, null, null, "Is Recursive (shows on child pages)")
            </div>
        }
        <hr class="small-margin" />
        @Html.RenderCustomAdminProperties()

        
        @if (Model.IsTypeCachable())
        {
            <hr />
            <h4>@Resource("Advanced")</h4>
            <hr class="small-margin" />
            <div class="form-group">
                @Html.InlineCheckboxFor(widget => widget.Cache)
            </div>
            <div class="form-group">
                @Html.LabelFor(widget => widget.CacheLength)
                @Html.TextBoxFor(widget => widget.CacheLength, new { @class = "form-control" })
                @Html.ValidationMessageFor(widget => widget.CacheLength)
            </div>
            <div class="form-group">
                @Html.LabelFor(widget => widget.CacheExpiryType)
                @Html.DropDownListFor(widget => widget.CacheExpiryType, cacheExpiryOptions, new { @class = "form-control" })
                @Html.ValidationMessageFor(widget => widget.CacheExpiryType)
            </div>
        }
    </fieldset>
}